 class CreateCourses < ActiveRecord::Migration
  def self.up
    create_table :courses do |t|
      t.string :name, :limit => 100, :null => false
      t.string :classroom, :limit => 20, :null => false
      t.integer :duration, :null => false
      t.date :started_at, :null => false
      t.date :finished_at, :null => false
      t.text :menu, :null => false
      t.text :objective, :null => false
      t.text :programatic_content, :null => false
      t.text :bibliography, :null => false
      t.string :published, :null => false, :limit => 1, :default => "N"
      t.integer :maximum, :null => false
      t.integer :minimum, :null => false
      t.references :user, :null => false
      t.references :category, :null => false
      t.references :hyperlink
      t.references :lesson
      t.references :advice
      t.references :enrollment
      t.references :forum

      t.timestamps
    end

    add_index(:courses, [:name,:classroom,:started_at,:user_id], :unique => true, :name => "uk_name_classroom_started_user")
  end

  def self.down
    drop_table :courses
  end
end
